package org.jeecg.modules.lab.items.ibasis.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.lab.items.entity.LabItemsBasis;
import org.jeecg.modules.lab.items.ibasis.mapper.LabItemsBasisMapper;
import org.jeecg.modules.lab.items.ibasis.service.ILabItemsBasisService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 项目依据信息表
 * @Author: jeecg-boot
 * @Date:   2023-08-24
 * @Version: V1.0
 */
@Service
public class LabItemsBasisServiceImpl extends ServiceImpl<LabItemsBasisMapper, LabItemsBasis> implements ILabItemsBasisService {

    @Autowired
    private LabItemsBasisMapper labItemsBasisMapper;


    @Override
    public LabItemsBasis queryOne(String name, String itemId) {
        List<LabItemsBasis> basisbyItemId = labItemsBasisMapper.getBasisbyItemId(itemId);
        List<LabItemsBasis> labItemsBases = labItemsBasisMapper.selectList(new LambdaQueryWrapper<LabItemsBasis>().like(LabItemsBasis::getName, name));
        LabItemsBasis labItemsBasis = new LabItemsBasis();
        for (int i = 0; i < labItemsBases.size(); i++) {
            for (int j = 0; j < basisbyItemId.size(); j++) {
                if(labItemsBases.get(i).getId().equals(basisbyItemId.get(j).getId())){
                    BeanUtils.copyProperties(labItemsBases.get(i),labItemsBasis);
//                  return labItemsBases.get(i);
                }
            }
        }
        return labItemsBasis;
    }

    @Override
    public LabItemsBasis getItemsBasis(String num) {
        return labItemsBasisMapper.getItemsBasis(num);
    }
}
